from setenv import setLotteryDir
from setenv import getFileDir
from setenv import getFileName


dlt_red={}
dlt_blue={}
guize={}

filedir=""
dltqfilename=""

redAll=35
blueAll=12
redNum=5
blueNum=2
dqnum=[]


def pp(dic):
    for i in dic.keys():
        if dic[i] :
          print( str(i) ,end = " ")



def csh_guize():

    global guize

    guize[0] = "未中奖"
    guize[10] = "未中奖"
    guize[20] = "未中奖"
    guize[30] = "九等奖"
    guize[40] = "七等奖"
    guize[50] = "三等奖"
    guize[1]  = "未中奖"
    guize[11] = "未中奖"
    guize[21] = "九等奖"
    guize[31] = "八等奖"
    guize[41] = "五等奖"
    guize[51] = "二等奖"
    guize[2]  = "九等奖"
    guize[12] = "九等奖"
    guize[22] = "八等奖"
    guize[32] = "六等奖"
    guize[42] = "四等奖"
    guize[52] = "一等奖"
    setLotteryDir()
    global filedir
    filedir = getFileDir()
    global dltfilename
    dltfilename = getFileName("dltfilename")
    # print(filedir)
    # print(dltqfilename)
    global dqnum

    with open( str(filedir) + "/" + str(dltfilename), "r") as file:
        # 写入数据
        dqnum = file.read().strip().split(" ")

    file.close
    print("当期中奖号码：" + str(dqnum))



def bijiao(filename):
    global dlt_red
    global dlt_blue

    for i in range(1, redAll+1):
        dlt_red[i] = False
    for i in range(1, blueAll+1):
        dlt_blue[i] = False

    with open(str(filedir) + "/" + str(filename) ,"r") as file:
        dlt = file.read().strip().split(" ")
    file.close
#    print(str(dlt_sj))
    for i in range(0,redNum):
        dlt_red[int(dlt[i])] = True

    for i in range(redNum,redNum+blueNum):
        dlt_blue[int(dlt[i])] = True

    red = 0
    for i in range(0,redNum):
        if dlt_red[int(dqnum[i])] :
            red += 1
    blue = 0
    for i in range(redNum,redNum + blueNum):
        if dlt_blue[int(dqnum[i])] :
            blue += 1

    result = int(str(red) + str(blue))

    if filename == "dlt-sj.txt" :
        print("随机选号：")
    if filename == "dlt-gd.txt" :
        print("固定选号：")
        
    pp(dlt_red)
    pp(dlt_blue)

    print("red：" + str(red) + "，blue：" + str(blue) + "。结论：" + guize[result])


if __name__ == '__main__':

     csh_guize()
     bijiao("dlt-gd.txt")
     bijiao("dlt-sj.txt")
